const http = require('http');

const server = http.createServer((req, res) => {
  if (req.url !== '/favicon.ico') {
    res.writeHead('200', { 'content-type': 'text/html;charset=utf-8'})
    console.log(req.url)
    let str = ''
    switch (req.url) {
      case '/home':
        str = '首页'
        break
      case '/category': 
        str = '分类'
        break
      case '/cart':
        str = '购物车'
        break
      case '/user':
        str = '个人中心'
        break
      default:
        str = '404'
        break
    }
    res.write(str);
    res.end()
  }
})

server.listen(3000)